home *** CD-ROM | disk | FTP | other *** search
/ Motor Sport Digital Archive Collection 1960s / Motor Sport Digital Archive Collection 1960s.iso / main.swf / scripts / views / SpreadsTab.as < prev    next >
Encoding:
Text File  |  2008-05-21  |  15.2 KB  |  448 lines

  1. package views
  2. {
  3.    import events.NavigationEvent;
  4.    import flash.accessibility.*;
  5.    import flash.debugger.*;
  6.    import flash.display.*;
  7.    import flash.errors.*;
  8.    import flash.events.*;
  9.    import flash.external.*;
  10.    import flash.filters.*;
  11.    import flash.geom.*;
  12.    import flash.media.*;
  13.    import flash.net.*;
  14.    import flash.printing.*;
  15.    import flash.profiler.*;
  16.    import flash.system.*;
  17.    import flash.text.*;
  18.    import flash.ui.*;
  19.    import flash.utils.*;
  20.    import flash.xml.*;
  21.    import model.PresentationModel;
  22.    import mx.binding.*;
  23.    import mx.binding.utils.ChangeWatcher;
  24.    import mx.collections.ArrayCollection;
  25.    import mx.containers.Canvas;
  26.    import mx.containers.VBox;
  27.    import mx.controls.Image;
  28.    import mx.core.Repeater;
  29.    import mx.core.UIComponentDescriptor;
  30.    import mx.core.mx_internal;
  31.    import mx.events.FlexEvent;
  32.    import mx.events.PropertyChangeEvent;
  33.    import mx.styles.*;
  34.    
  35.    public class SpreadsTab extends Canvas
  36.    {
  37.       private static var _watcherSetupUtil:IWatcherSetupUtil;
  38.       
  39.       private var _bindings:Array;
  40.       
  41.       public var _bindingsByDestination:Object;
  42.       
  43.       [Bindable]
  44.       private var _907050744spreadsRepeater:Repeater;
  45.       
  46.       [Bindable]
  47.       private var _1493698499_VBox1:VBox;
  48.       
  49.       [Bindable]
  50.       private var _874346147thumbs:ArrayCollection;
  51.       
  52.       public var _bindingsBeginWithWord:Object;
  53.       
  54.       public var myWatcher:ChangeWatcher;
  55.       
  56.       [Bindable]
  57.       private var _1857328081presentationModel:PresentationModel;
  58.       
  59.       [Bindable]
  60.       private var _2145370147spreadThumb:Array;
  61.       
  62.       private var currentIssue:int = -1;
  63.       
  64.       private var _embed_mxml____embedded_assets_spreads_tab_bg_png_224686987:Class;
  65.       
  66.       private var _watchers:Array;
  67.       
  68.       private var _documentDescriptor_:UIComponentDescriptor;
  69.       
  70.       public function SpreadsTab()
  71.       {
  72.          _documentDescriptor_ = new UIComponentDescriptor({
  73.             "type":Canvas,
  74.             "propertiesFactory":function():Object
  75.             {
  76.                return {
  77.                   "width":206,
  78.                   "height":926,
  79.                   "childDescriptors":[new UIComponentDescriptor({
  80.                      "type":Image,
  81.                      "propertiesFactory":function():Object
  82.                      {
  83.                         return {
  84.                            "source":_embed_mxml____embedded_assets_spreads_tab_bg_png_224686987,
  85.                            "width":206,
  86.                            "height":926
  87.                         };
  88.                      }
  89.                   }),new UIComponentDescriptor({
  90.                      "type":VBox,
  91.                      "id":"_VBox1",
  92.                      "stylesFactory":function():void
  93.                      {
  94.                         this.verticalGap = 10;
  95.                         this.paddingTop = 30;
  96.                         this.paddingBottom = 30;
  97.                         this.paddingLeft = 10;
  98.                         this.paddingRight = 20;
  99.                         this.horizontalAlign = "center";
  100.                         this.backgroundColor = 14277081;
  101.                      },
  102.                      "propertiesFactory":function():Object
  103.                      {
  104.                         return {
  105.                            "verticalLineScrollSize":10,
  106.                            "x":6,
  107.                            "y":15,
  108.                            "width":188,
  109.                            "height":885,
  110.                            "horizontalScrollPolicy":"off",
  111.                            "childDescriptors":[new UIComponentDescriptor({
  112.                               "type":Repeater,
  113.                               "id":"spreadsRepeater",
  114.                               "propertiesFactory":function():Object
  115.                               {
  116.                                  return {"childDescriptors":[new UIComponentDescriptor({
  117.                                     "type":SpreadThumb,
  118.                                     "id":"spreadThumb",
  119.                                     "events":{
  120.                                        "click":"__spreadThumb_click",
  121.                                        "rollOver":"__spreadThumb_rollOver",
  122.                                        "rollOut":"__spreadThumb_rollOut"
  123.                                     },
  124.                                     "propertiesFactory":function():Object
  125.                                     {
  126.                                        return {
  127.                                           "buttonMode":true,
  128.                                           "width":140
  129.                                        };
  130.                                     }
  131.                                  })]};
  132.                               }
  133.                            })]
  134.                         };
  135.                      }
  136.                   })]
  137.                };
  138.             }
  139.          });
  140.          currentIssue = -1;
  141.          _embed_mxml____embedded_assets_spreads_tab_bg_png_224686987 = SpreadsTab__embed_mxml____embedded_assets_spreads_tab_bg_png_224686987;
  142.          super();
  143.          mx_internal::_document = this;
  144.          this.width = 206;
  145.          this.height = 926;
  146.          this.addEventListener("creationComplete",___Canvas1_creationComplete);
  147.       }
  148.       
  149.       public static function set watcherSetupUtil(param1:IWatcherSetupUtil) : void
  150.       {
  151.          SpreadsTab._watcherSetupUtil = param1;
  152.       }
  153.       
  154.       private function pgNumber(param1:int) : String
  155.       {
  156.          var _loc2_:String = null;
  157.          _loc2_ = param1.toString();
  158.          if(10 > param1)
  159.          {
  160.             _loc2_ = "0" + _loc2_;
  161.          }
  162.          if(100 > param1)
  163.          {
  164.             _loc2_ = "0" + _loc2_;
  165.          }
  166.          return _loc2_;
  167.       }
  168.       
  169.       private function _SpreadsTab_bindingExprs() : void
  170.       {
  171.          var _loc1_:* = undefined;
  172.          _loc1_ = thumbs;
  173.          _loc1_ = getHighlightStyle(presentationModel.currentPage,spreadsRepeater.currentIndex);
  174.          _loc1_ = formatText(spreadsRepeater.currentIndex);
  175.          _loc1_ = spreadsRepeater.currentItem;
  176.       }
  177.       
  178.       [Bindable(event="propertyChange")]
  179.       public function get spreadThumb() : Array
  180.       {
  181.          return this._2145370147spreadThumb;
  182.       }
  183.       
  184.       public function set spreadThumb(param1:Array) : void
  185.       {
  186.          var _loc2_:Object = null;
  187.          _loc2_ = this._2145370147spreadThumb;
  188.          if(_loc2_ !== param1)
  189.          {
  190.             this._2145370147spreadThumb = param1;
  191.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"spreadThumb",_loc2_,param1));
  192.          }
  193.       }
  194.       
  195.       [Bindable(event="propertyChange")]
  196.       public function get _VBox1() : VBox
  197.       {
  198.          return this._1493698499_VBox1;
  199.       }
  200.       
  201.       public function set presentationModel(param1:PresentationModel) : void
  202.       {
  203.          var _loc2_:Object = null;
  204.          _loc2_ = this._1857328081presentationModel;
  205.          if(_loc2_ !== param1)
  206.          {
  207.             this._1857328081presentationModel = param1;
  208.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"presentationModel",_loc2_,param1));
  209.          }
  210.       }
  211.       
  212.       public function set _VBox1(param1:VBox) : void
  213.       {
  214.          var _loc2_:Object = null;
  215.          _loc2_ = this._1493698499_VBox1;
  216.          if(_loc2_ !== param1)
  217.          {
  218.             this._1493698499_VBox1 = param1;
  219.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_VBox1",_loc2_,param1));
  220.          }
  221.       }
  222.       
  223.       [Bindable(event="propertyChange")]
  224.       public function get presentationModel() : PresentationModel
  225.       {
  226.          return this._1857328081presentationModel;
  227.       }
  228.       
  229.       private function rollOutHandler(param1:Event) : void
  230.       {
  231.          if(param1.target.repeaterIndex == presentationModel.currentPage)
  232.          {
  233.             param1.target.oldStyle = "spreadThumbHighlight";
  234.          }
  235.          param1.target.style = param1.target.oldStyle;
  236.       }
  237.       
  238.       private function clickHandler(param1:Event) : void
  239.       {
  240.          var _loc2_:int = 0;
  241.          _loc2_ = int(param1.currentTarget.repeaterIndex);
  242.          dispatchEvent(new NavigationEvent(NavigationEvent.SELECT_PAGE,_loc2_,true));
  243.       }
  244.       
  245.       [Bindable(event="propertyChange")]
  246.       public function get spreadsRepeater() : Repeater
  247.       {
  248.          return this._907050744spreadsRepeater;
  249.       }
  250.       
  251.       private function init() : void
  252.       {
  253.          myWatcher = ChangeWatcher.watch(this,["presentationModel","currentIssue"],presentationModelListener);
  254.          thumbs = new ArrayCollection(new Array());
  255.       }
  256.       
  257.       [Bindable(event="propertyChange")]
  258.       private function get thumbs() : ArrayCollection
  259.       {
  260.          return this._874346147thumbs;
  261.       }
  262.       
  263.       public function __spreadThumb_rollOut(param1:MouseEvent) : void
  264.       {
  265.          rollOutHandler(param1);
  266.       }
  267.       
  268.       private function formatText(param1:int) : String
  269.       {
  270.          var _loc2_:String = null;
  271.          var _loc3_:int = 0;
  272.          if(-1 == param1 || -1 == presentationModel.numPages)
  273.          {
  274.             return "";
  275.          }
  276.          _loc2_ = "" + param1.toString();
  277.          if(0 == param1)
  278.          {
  279.             _loc2_ = "" + 1;
  280.          }
  281.          else if(param1 == presentationModel.numPages - 1 && false == presentationModel.twoPageBack)
  282.          {
  283.             _loc2_ = "" + param1 * 2;
  284.          }
  285.          else
  286.          {
  287.             _loc3_ = param1 * 2;
  288.             _loc2_ = "" + _loc3_ + " & " + ++_loc3_;
  289.          }
  290.          return _loc2_;
  291.       }
  292.       
  293.       public function presentationModelListener(param1:PropertyChangeEvent) : void
  294.       {
  295.          var _loc2_:String = null;
  296.          var _loc3_:String = null;
  297.          var _loc4_:int = 0;
  298.          var _loc5_:Array = null;
  299.          var _loc6_:int = 0;
  300.          trace("presentationModel has changed curr " + currentIssue + ", p.curr " + presentationModel.currentIssue + ", pages " + presentationModel.numPages + ", issues " + presentationModel.issues);
  301.          _loc2_ = presentationModel.yearString;
  302.          if(null == presentationModel.issues || -1 == presentationModel.numPages)
  303.          {
  304.             return;
  305.          }
  306.          if(-1 != currentIssue && currentIssue == presentationModel.currentIssue)
  307.          {
  308.             return;
  309.          }
  310.          currentIssue = presentationModel.currentIssue;
  311.          _loc3_ = presentationModel.filePrefix;
  312.          _loc4_ = presentationModel.numPages;
  313.          _loc5_ = new Array(_loc4_);
  314.          trace("presentationModel changed: now I am here " + _loc3_ + ", " + _loc4_);
  315.          _loc6_ = 0;
  316.          while(_loc6_ < _loc4_)
  317.          {
  318.             _loc5_[_loc6_] = _loc2_ + "/" + _loc3_ + "-" + pgNumber(_loc6_) + ".jpg";
  319.             _loc6_++;
  320.          }
  321.          thumbs = new ArrayCollection(_loc5_);
  322.       }
  323.       
  324.       public function set spreadsRepeater(param1:Repeater) : void
  325.       {
  326.          var _loc2_:Object = null;
  327.          _loc2_ = this._907050744spreadsRepeater;
  328.          if(_loc2_ !== param1)
  329.          {
  330.             this._907050744spreadsRepeater = param1;
  331.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"spreadsRepeater",_loc2_,param1));
  332.          }
  333.       }
  334.       
  335.       private function getHighlightStyle(param1:int, param2:int) : String
  336.       {
  337.          trace("getHighlightStyle " + param1 + " current " + param2);
  338.          return param2 == param1 ? "spreadThumbHighlight" : "spreadThumbNormal";
  339.       }
  340.       
  341.       public function ___Canvas1_creationComplete(param1:FlexEvent) : void
  342.       {
  343.          init();
  344.       }
  345.       
  346.       public function __spreadThumb_click(param1:MouseEvent) : void
  347.       {
  348.          clickHandler(param1);
  349.       }
  350.       
  351.       private function set thumbs(param1:ArrayCollection) : void
  352.       {
  353.          var _loc2_:Object = null;
  354.          _loc2_ = this._874346147thumbs;
  355.          if(_loc2_ !== param1)
  356.          {
  357.             this._874346147thumbs = param1;
  358.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"thumbs",_loc2_,param1));
  359.          }
  360.       }
  361.       
  362.       private function rollOverHandler(param1:Event) : void
  363.       {
  364.          param1.target.oldStyle = param1.target.style;
  365.          param1.target.style = "spreadThumbHighlight";
  366.       }
  367.       
  368.       public function __spreadThumb_rollOver(param1:MouseEvent) : void
  369.       {
  370.          rollOverHandler(param1);
  371.       }
  372.       
  373.       override public function initialize() : void
  374.       {
  375.          var target:SpreadsTab = null;
  376.          var watcherSetupUtilClass:Object = null;
  377.          mx_internal::setDocumentDescriptor(_documentDescriptor_);
  378.          _SpreadsTab_bindingsSetup();
  379.          target = this;
  380.          if(_watcherSetupUtil == null)
  381.          {
  382.             watcherSetupUtilClass = getDefinitionByName("_views_SpreadsTabWatcherSetupUtil");
  383.             watcherSetupUtilClass["init"](null);
  384.          }
  385.          _watcherSetupUtil.setup(this,function(param1:String):*
  386.          {
  387.             return target[param1];
  388.          },_bindings,_watchers);
  389.          super.initialize();
  390.       }
  391.       
  392.       private function _SpreadsTab_bindingsSetup() : void
  393.       {
  394.          var binding:Binding = null;
  395.          if(!_bindings)
  396.          {
  397.             _bindings = [];
  398.          }
  399.          if(!_watchers)
  400.          {
  401.             _watchers = [];
  402.          }
  403.          binding = new Binding(this,function():Object
  404.          {
  405.             return thumbs;
  406.          },function(param1:Object):void
  407.          {
  408.             spreadsRepeater.dataProvider = param1;
  409.          },"spreadsRepeater.dataProvider");
  410.          _bindings[0] = binding;
  411.          binding = new RepeatableBinding(this,function(param1:Array, param2:Array):String
  412.          {
  413.             var _loc3_:* = undefined;
  414.             var _loc4_:* = undefined;
  415.             _loc3_ = getHighlightStyle(presentationModel.currentPage,param2[0]);
  416.             return _loc3_ == undefined ? null : String(_loc3_);
  417.          },function(param1:String, param2:Array):void
  418.          {
  419.             spreadThumb[param2[0]].style = param1;
  420.          },"spreadThumb.style");
  421.          _bindings[1] = binding;
  422.          binding = new RepeatableBinding(this,function(param1:Array, param2:Array):String
  423.          {
  424.             var _loc3_:* = undefined;
  425.             var _loc4_:* = undefined;
  426.             _loc3_ = formatText(param2[0]);
  427.             return _loc3_ == undefined ? null : String(_loc3_);
  428.          },function(param1:String, param2:Array):void
  429.          {
  430.             spreadThumb[param2[0]].page = param1;
  431.          },"spreadThumb.page");
  432.          _bindings[2] = binding;
  433.          binding = new RepeatableBinding(this,function(param1:Array, param2:Array):String
  434.          {
  435.             var _loc3_:* = undefined;
  436.             var _loc4_:* = undefined;
  437.             _loc3_ = spreadsRepeater.mx_internal::getItemAt(param2[0]);
  438.             return _loc3_ == undefined ? null : String(_loc3_);
  439.          },function(param1:String, param2:Array):void
  440.          {
  441.             spreadThumb[param2[0]].imageURL = param1;
  442.          },"spreadThumb.imageURL");
  443.          _bindings[3] = binding;
  444.       }
  445.    }
  446. }
  447.  
  448.